package com.superhelper.task;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    private static final Logger log = LoggerFactory.getLogger(App.class);
    private static ClassPathXmlApplicationContext context;

    public static void main(String[] args) throws IOException, InterruptedException {
        String active = System.getProperty("spring.profiles.active");
        if (StringUtils.isBlank(active)) {
            System.setProperty("spring.profiles.active", "test");
        }
        initializeApplicationContext(new String[] { "classpath:/configs/app-context.xml" });
    }

    private static void initializeApplicationContext(String[] resource) throws InterruptedException {
        context = new ClassPathXmlApplicationContext(resource);
        context.start();
        // StatDailyOrderJob jb = context.getBean(StatDailyOrderJob.class);
        // jb.execute(null);
        log.info("superhelper task start success..............");
        synchronized (App.class) {
            try {
                App.class.wait();
            } catch (InterruptedException e) {
            }
        }

    }
}
